/*
 *	ApOS (Another Project software for s3c2410)
 *	
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *			
 *
 */
#ifndef _NAND_FLASH_H
#define _NAND_FLASH_H

#define TACLS		0  //1clk(0ns) 
#define TWRPH0		3  //3clk(25ns)
#define TWRPH1		0  //1clk(10ns)  //TACLS+TWRPH0+TWRPH1>=50ns

#define BLOCK_SECTOR(b,n)	(512*32*(b)+(n))

//send command
#define NF_CMD(cmd)	{rNFCMD=cmd;}
//set address
#define NF_ADDR(addr)	{rNFADDR=addr;}
//NAND Flash Memory chip enable
#define NF_nFCE_L()	{rNFCONF&=~(1<<11);}
//NAND Flash Memory chip disable
#define NF_nFCE_H()	{rNFCONF|=(1<<11);}
//Initialize ECC
#define NF_RSTECC()	{rNFCONF|=(1<<12);}
//read data
#define NF_RDDATA()	(rNFDATA)
//write data
#define NF_WRDATA(data)	{rNFDATA=data;}
//get status
#define NF_WAITRB()	{while(!(rNFSTAT&(1)));}

#define BLOCK(n) 	((n)*512*32)

#endif

